//
//  YMStationAnnotationView.swift
//  Driver
//
//  Created by lantaiyuan on 2017/11/1.
//  Copyright © 2017年 youmy. All rights reserved.
//

import Foundation

class YMStationAnnotationView: MAAnnotationView {
    
    let kWidth:CGFloat = 10.0
    let kHeight:CGFloat = 10.0
    
    override func draw(_ rect: CGRect) {
        
        let context = UIGraphicsGetCurrentContext()
        
        guard let strokeColor = UIColor.init(hexString: "#5298ff") else {
            return
        }
        
        context?.setLineWidth(1)
        context?.setStrokeColor(strokeColor.cgColor)
        context?.setFillColor(UIColor.white.cgColor)
        context?.addArc(center: CGPoint.init(x: kWidth / 2.0, y: kHeight / 2.0), radius: 4, startAngle: 0, endAngle: .pi * 2, clockwise: false)
        context?.drawPath(using: .fillStroke)
        
        super.draw(rect)
    }
    
    override init!(annotation: MAAnnotation!, reuseIdentifier: String!) {
        super.init(annotation: annotation, reuseIdentifier: reuseIdentifier)
        backgroundColor = .clear
        self.centerOffset = CGPoint.init(x: 0, y: -kHeight/2.0)
        self.bounds = CGRect(x: 0, y: 0, width: kWidth, height: kHeight)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
